/**
 * 用户模块接口文件
 */

import axios from './request';

/**
 * 角色接口
 */
export interface IRoles extends IRolesAdd {
    id: number;
}

/**
 * 添加接口
 */
export interface IRolesAdd {
    name: string;
    description: string;
}

/**
 * 获取列表
 * @returns 
 */
export const getList = (): Promise<IRoles[]> => axios.get('/roles/all');

/**
 * 添加角色
 * @param roles 
 * @returns 
 */
export const add = (roles: IRolesAdd) => axios.post('/roles/add', roles);

/**
 * 更改角色
 * @param roles 
 * @returns 
 */
export const update = (roles: IRoles) => axios.put('/roles/update', roles);

/**
 * 删除角色
 * @param id 
 * @returns 
 */
export const deleteRoles = (id: number) => axios.delete('/roles/delete/' + id);

/**
 * 设置权限
 * @param role_id 
 * @param menu_ids 
 * @returns 
 */
export const setRights = (role_id: number, menu_ids: number[]) => axios.put('/roles/setRights', {
    role_id,
    menu_ids
});